home *** CD-ROM | disk | FTP | other *** search
/ Your Web Site Creator / Your Web Site Creator.iso / WebSite / data1.cab / Program_Executable_Files / Classes / PULSING2.CLA (.txt) < prev    next >
Encoding:
Java Class File  |  1999-01-13  |  3.2 KB  |  144 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.image.ImageObserver;
  7.  
  8. public class PulsingBorderPanel2 extends DynamicBorderPanel2 {
  9.    int red;
  10.    int green;
  11.    int blue;
  12.    int origRed;
  13.    int origGreen;
  14.    int origBlue;
  15.    int redIncrement;
  16.    int greenIncrement;
  17.    int blueIncrement;
  18.    final int increment = 25;
  19.    Image osImage;
  20.    Graphics osg;
  21.    int count;
  22.    Color[] theColors;
  23.    int colorIncrement = 1;
  24.  
  25.    void GetParameters(Applet var1, int var2) {
  26.       String var3 = var1.getParameter("pulsingBorderThickness" + var2);
  27.       ((BorderPanel2)this).SetThickness(AppletParam2.GetInt(var3, 5));
  28.       var3 = var1.getParameter("pulsingBorderBkColor" + var2);
  29.       ((BorderPanel2)this).SetBackgroundColor(AppletParam2.GetColor(var3, (Color)null));
  30.       var3 = var1.getParameter("pulsingBorderBkImage" + var2);
  31.       ((BorderPanel2)this).SetBackgroundImage(AppletParam2.GetImage(var1, var3));
  32.       var3 = var1.getParameter("pulsingBorderColor" + var2);
  33.       this.SetColor(AppletParam2.GetColor(var3, Color.red));
  34.    }
  35.  
  36.    public PulsingBorderPanel2(Applet var1, int var2) {
  37.       this.GetParameters(var1, var2);
  38.    }
  39.  
  40.    public void SetColor(Color var1) {
  41.       this.origRed = var1.getRed();
  42.       this.origGreen = var1.getGreen();
  43.       this.origBlue = var1.getBlue();
  44.       this.red = this.origRed;
  45.       this.green = this.origGreen;
  46.       this.blue = this.origBlue;
  47.       this.redIncrement = (255 - this.red) / 25;
  48.       this.greenIncrement = (255 - this.green) / 25;
  49.  
  50.       for(this.blueIncrement = (255 - this.blue) / 25; this.red <= 255 && this.green <= 255 && this.blue <= 255; ++this.count) {
  51.          this.red += this.redIncrement;
  52.          this.green += this.greenIncrement;
  53.          this.blue += this.blueIncrement;
  54.       }
  55.  
  56.       this.theColors = new Color[this.count];
  57.       this.red = this.origRed;
  58.       this.green = this.origGreen;
  59.       this.blue = this.origBlue;
  60.  
  61.       for(this.count = 0; this.red <= 255 && this.green <= 255 && this.blue <= 255; ++this.count) {
  62.          this.theColors[this.count] = new Color(this.red, this.green, this.blue);
  63.          this.red += this.redIncrement;
  64.          this.green += this.greenIncrement;
  65.          this.blue += this.blueIncrement;
  66.       }
  67.  
  68.       this.red = this.origRed;
  69.       this.green = this.origGreen;
  70.       this.blue = this.origBlue;
  71.       this.count = 0;
  72.    }
  73.  
  74.    void DoPaint(Graphics var1) {
  75.       if (this.osImage == null) {
  76.          this.osImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  77.          this.osg = this.osImage.getGraphics();
  78.       }
  79.  
  80.       this.osg.setColor(this.theColors[this.count]);
  81.       this.count += this.colorIncrement;
  82.  
  83.       for(int var2 = 0; var2 < super.thickness; ++var2) {
  84.          this.osg.drawRect(var2, var2, ((Component)this).size().width - 2 * var2 - 1, ((Component)this).size().height - 2 * var2 - 1);
  85.       }
  86.  
  87.       this.red += this.redIncrement;
  88.       this.green += this.greenIncrement;
  89.       this.blue += this.blueIncrement;
  90.       if (this.red > 255) {
  91.          this.red = 255;
  92.       }
  93.  
  94.       if (this.green > 255) {
  95.          this.green = 255;
  96.       }
  97.  
  98.       if (this.blue > 255) {
  99.          this.blue = 255;
  100.       }
  101.  
  102.       if (this.count >= this.theColors.length) {
  103.          this.count = this.theColors.length - 1;
  104.       }
  105.  
  106.       if (this.red == 255 && this.green == 255 && this.blue == 255) {
  107.          this.redIncrement = -this.redIncrement;
  108.          this.greenIncrement = -this.greenIncrement;
  109.          this.blueIncrement = -this.blueIncrement;
  110.          this.colorIncrement = -this.colorIncrement;
  111.       }
  112.  
  113.       if (this.red < this.origRed) {
  114.          this.red = this.origRed;
  115.       }
  116.  
  117.       if (this.green < this.origGreen) {
  118.          this.green = this.origGreen;
  119.       }
  120.  
  121.       if (this.blue < this.origBlue) {
  122.          this.blue = this.origBlue;
  123.       }
  124.  
  125.       if (this.count < 0) {
  126.          this.count = 0;
  127.       }
  128.  
  129.       if (this.red == this.origRed && this.green == this.origGreen && this.blue == this.origBlue) {
  130.          this.redIncrement = -this.redIncrement;
  131.          this.greenIncrement = -this.greenIncrement;
  132.          this.blueIncrement = -this.blueIncrement;
  133.          this.colorIncrement = -this.colorIncrement;
  134.       }
  135.  
  136.       var1.drawImage(this.osImage, 0, 0, (ImageObserver)null);
  137.    }
  138.  
  139.    void DoResize(int var1, int var2) {
  140.       this.osImage = null;
  141.       this.osg = null;
  142.    }
  143. }
  144.